import React from "react";
import { Modal, Form, Row, Space, Button, Input, Select, message } from "antd";
import UploadImg from "@/components/Upload";
import { twuserUpdate } from './service';
import "./index.less";
const UserInfo = (props) => {
  const { isOpen, onClose, updateData, getList } = props;
  console.log(updateData.imgs, "updateData");
  const [form] = Form.useForm();
  form.setFieldsValue({
    ...updateData
  })

  const onCloseModal = () => {
    form.resetFields()
    onClose()
  }

  const onSubmit = async () => {
    const values = form.getFieldsValue()
    const res = await twuserUpdate({
      id: updateData.id,
      ...values
    })
    if (res) {
      message.success('更新成功')
      onClose()
      getList()
    }
  }
  // /back/twuser/update
  return (
    <Modal
      width={600}
      title="用户个人资料"
      open={isOpen}
      onOk={onSubmit}
      onCancel={onCloseModal}
    >
      <Form form={form} onFinish={() => console.log(1)}>
        <Form.Item name="imgs" label="头像">
          <UploadImg files={updateData.imgs} />
        </Form.Item>
        <Form.Item name="type" label="类型">
          <Select placeholder="请选择" options={[
            { value: 0, label: '买家' },
            { value: 1, label: '卖家' }
          ]}></Select>
        </Form.Item>
        <Form.Item name="mobile" label="手机">
          <Input placeholder="请输入" />
        </Form.Item>
        <Form.Item name="context" label="简介">
          <Input placeholder="请输入" />
        </Form.Item>
      </Form>
    </Modal>
  );
};
export default UserInfo;
